<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 求某个数的阶乘
        function factorial(n) {
            var mul = 1;
            for (var i = 1; i <= n; i++) {
                mul *= i;
            }
            return mul;
        }
        // 某个数的阶乘之和
        function factorialSum(n) {
            var sum = 0;
            for (var i = 1; i <= n; i++) {
                sum += factorial(i);
            }
            return sum;
        }
        
        var n = parseInt(prompt("请输入一个整数："));
        alert("阶乘之和为"+ factorialSum(n));
    </script>
</head>
<body>
    
</body>
</html>